/*
 * @Author: Dreamy Icecream 
 * @Date: 2020-12-30 17:11:14 
 * @Description: 亮度、饱和度和对比度
 * @Last Modified by: Dreamy Icecream
 * @Last Modified time: 2020-12-30 19:00:01
 */

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BrightnessSaturationAndContrast : PostEffectsBase {

	public Shader briSatConShader;
	private Material briSatConMaterial;

	/** 亮度 */
	[Range (0.0f, 3.0f)]
	public float brightness = 1.0f;

	/** 饱和度 */
	[Range (0.0f, 3.0f)]
	public float saturation = 1.0f;

	/** 对比度 */
	[Range (0.0f, 3.0f)]
	public float contrast = 1.0f;

	public Material material {
		get {
			this.briSatConMaterial = this.CheckShaderAndCreateMaterial (this.briSatConShader, this.briSatConMaterial);
			return this.briSatConMaterial;
		}
	}

	private void OnRenderImage (RenderTexture src, RenderTexture dest) {
		if (this.material != null) {
			this.material.SetFloat ("_Brightness", this.brightness);
			this.material.SetFloat ("_Saturation", this.saturation);
			this.material.SetFloat ("_Contrast", this.contrast);

			Graphics.Blit (src, dest, this.material);

		} else {
			Graphics.Blit (src, dest);
		}
	}

}